<template>
  <div class="stringdiv">
      <h6>{{tableSetJson.name}}</h6>
    <el-row class="eldiv1">
      <el-col :span="24">
        <el-input
          type="text"
          v-show="stringCount>0"
          :placeholder="setPlaceholder()"
          v-model="mulrenum.rnuRadioContent"
          v-on:input="getChangeStringValue()"
        >
        <template slot="prepend">{{labelStrings[0]}}：</template>
        </el-input>
        <el-input
          type="text"
          v-show="stringCount>1"
          :placeholder="setPlaceholder()"
          v-model="mulrenum.rnuContent"
          v-on:input="getChangeStringValue()"
        >
        <template slot="prepend">{{labelStrings[1]}}：</template>
        </el-input>
        <el-input
          type="text"
          v-show="stringCount>2"
          :placeholder="setPlaceholder()"
          v-model="mulrenum.rnuContent1"
          v-on:input="getChangeStringValue()"
        >
        <template slot="prepend">{{labelStrings[2]}}：</template>
        </el-input>
        <el-input
          type="text"
          v-show="stringCount>3"
          :placeholder="setPlaceholder()"
          v-model="mulrenum.rnuContent2"
          v-on:input="getChangeStringValue()"
        >
        <template slot="prepend">{{labelStrings[3]}}：</template>
        </el-input>
        <el-input
          type="text"
          v-show="stringCount>4"
          :placeholder="setPlaceholder()"
          v-model="mulrenum.rnuRadioContent1"
          v-on:input="getChangeStringValue()"
        >
        <template slot="prepend">{{labelStrings[4]}}：</template>
        </el-input>
        <el-input
          type="text"
          v-show="stringCount>5"
          :placeholder="setPlaceholder()"
          v-model="mulrenum.rnuRadioContent2"
          v-on:input="getChangeStringValue()"
        >
        <template slot="prepend">{{labelStrings[5]}}：</template>
        </el-input>
      </el-col>
    </el-row>
     <el-row style="margin-bottom: 3px">
         <el-col :span="24">
             <el-input
                     disabled
                     type="text"
                     v-model="tableSetJson.labeltip"
             >
                 <template slot="prepend">设计要求：</template>
             </el-input>
         </el-col>
     </el-row>
  </div>
</template>

<script>
export default {
  name: "multistringinput",
  props: {
    tableSetJson: {
      type: Object
    },
    renumin: {
      type: Object
    }
  },
  watch: {
    mulrenum:{
      handler(newVal, oldVal) {
        this.$emit("listenTomultistringinput", newVal);
      }
    }
  },
  data() {
    return {
      mulrenum: this.renumin,
      tableStyle:this.tableSetJson,
      stringCount:0,
      labelStrings:[]
    };
  },
    created() {
        this.initString();
        this.getResult();
    },
  methods: {
      initString(){
          this.labelStrings = this.tableStyle.label.split(",");
          this.stringCount =  this.labelStrings.length;
      },
      getResult(){
          if(this.mulrenum.rnuRadioContent==""){
              this.mulrenum.rnuRadioContent =this.tableStyle.texttip;
              this.$emit("listenTomultistringinput", this.mulrenum);
          }
      },


    /* 往父节点传值的方法 */
    getChangeStringValue() {
      this.mulrenum.rnuCode = this.tableSetJson.name;
      this.mulrenum.rnuType = this.tableSetJson.type;   
      this.mulrenum.rnuNo = this.tableSetJson.orderno;
      /* 子组件主动发送数据给父组件 */
      this.$emit("listenTomultistringinput", this.mulrenum);
    },
    setPlaceholder() {
      return this.tableSetJson.texttip;
    }
  }
};
</script>
<style>
.stringdiv {
  width: 724px;
  margin-left: 5px;
  margin-top: 5px;
  margin-bottom: 5px;
  background-color: #f3f3f3;
}
</style>


